#ifndef MEMORY_ALLOCATOR_CONFIGURE_H
#define MEMORY_ALLOCATOR_CONFIGURE_H
/************************************************************************/
/* Memory allocator strategy:                                           */
/*      In the debug mode, use default std allocator and in the release */
/*      mode, use the Intel TBB memory allocate for high memory         */
/*      operation speed                                                 */
/************************************************************************/

#ifndef _DEBUG
#include <tbb\scalable_allocator.h>
inline void* operator new (size_t size) throw (std::bad_alloc)
{
    if (size == 0) size = 1;
    if (void* ptr = scalable_malloc (size))
        return ptr;
    throw std::bad_alloc ( );
}

inline void* operator new[] (size_t size) throw (std::bad_alloc)
{
    return operator new (size);
}

inline void* operator new (size_t size, const std::nothrow_t&) throw ( )
{
    if (size == 0) size = 1;
    if (void* ptr = scalable_malloc (size))
        return ptr;
    return NULL;
}

inline void* operator new[] (size_t size, const std::nothrow_t&) throw ( )
{
    return operator new (size, std::nothrow);
}

inline void operator delete (void* ptr) throw ( )
{
    if (ptr != 0) scalable_free (ptr);
}

inline void operator delete[] (void* ptr) throw ( )
{
    operator delete (ptr);
}

inline void operator delete (void* ptr, const std::nothrow_t&) throw ( )
{
    if (ptr != 0) scalable_free (ptr);
}

inline void operator delete[] (void* ptr, const std::nothrow_t&) throw ( )
{
    operator delete (ptr, std::nothrow);
}
#endif

#endif